package logshandler

import (
	"github.com/gin-gonic/gin"
	"yundian/internel/app/dao"
	"yundian/internel/app/helper/request"
	"yundian/internel/pkg/dingo"
	. "yundian/internel/pkg/dingo/result"
)

// GetLoginLogsList 获取定单列表API
func GetLoginLogsList(ctx *gin.Context) {
	param := &request.LoginLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewLoginLogsDao().GetLoginLogsList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}

//  获取计费修改日志列表API
func GetPlacePriceLogsList(ctx *gin.Context) {

	// 请求参数处理
	param := &request.PlacePriceLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()

	// 查询结果
	data := dao.NewPlacePriceLogsDao().GetPlacePriceLogsList(param)
	// 分页信息
	// 分页信息
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  0,
		Data:       data.Unwrap(),
	})(OK)
}

// 获取订单改动日志列表API
func GetOrderOperateLogList(ctx *gin.Context) {

	// 请求参数处理
	param := &request.OrderOperateLogReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()

	// 查询结果
	data := dao.NewUserDao().GetOrderOperateLog(param)
	// 分页信息
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  0,
		Data:       data.Unwrap(),
	})(OK)
}

// GetUserOperateLogList 用户信息变更日志列表 API
func GetUserOperateLogList(ctx *gin.Context) {
	param := &request.UserProfitLogReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewUserDao().GetUserProfitLog(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}

// 门店改动日志列表API
func GetPlaceOperateLogList(ctx *gin.Context) {

	// 请求参数处理
	param := &request.PlaceOperateLogReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()

	// 查询结果
	data := dao.NewUserDao().GetPlaceOperateLog(param)
	// 分页信息
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  0,
		Data:       data.Unwrap(),
	})(OK)
}

// HandleGetScanLogsList 获取扫码日志列表
func HandleGetScanLogsList(ctx *gin.Context) {
	// 请求参数处理
	param := &request.ScanLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()

	data := dao.NewScanLogsDao().GetScanLogsList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  0,
		Data:       data.Unwrap(),
	})(OK)
}

// GetDownloadLogsList 文件下载日志
func GetDownloadLogsList(ctx *gin.Context) {
	param := &request.FileDownLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewDownloadLogsDao().GetDownloadLogsList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}

// GetWxBindLogsList 微信绑定日志
func GetWxBindLogsList(ctx *gin.Context) {
	param := &request.WxBindLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewBindLogsDao().GetBindLogsList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}

// GetServiceClickLogsList 服务点击日志
func GetServiceClickLogsList(ctx *gin.Context) {
	param := &request.ServiceClickLogsListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewLiveServiceLogDao().GetLiveServiceLogList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}

// GetSpaLogsList 预约按摩日志
func GetSpaLogsList(ctx *gin.Context) {
	param := &request.SpaListReq{}
	dingo.ErrorIf(ctx.ShouldBindQuery(param)).Unwrap()
	data := dao.NewWyLogDao().GetWyLogList(param)
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       data.Unwrap(),
	})(OK)
}
